package com.jpa.dao;

import java.util.List;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.jpa.pojo.Role;

@Repository
public interface RoleDao extends BaseDao<Role, Long>{

	@Query(value = "select r.name,r.*  from  role r left join user_role ur on  ur.rid=r.rid left join user u on   ur.uid=u.uid where  u.username=:username", nativeQuery = true)
	List<Role> findRoles(@Param(value = "username") String username);

	@Query(value = "select r   from role r    where r.name=:name", nativeQuery = true)
	Role findByName(@Param(value = "name") String name);
	
	List<Role> findByRid(long rid);

}